package com.topnav.mc.admin.dao.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.topnav.mc.admin.entity.bean.UserBean;
import com.topnav.mc.admin.entity.bean.UserOrganizaitonBean;
import com.topnav.mc.admin.entity.param.UserOrganizaitonParam;
import com.topnav.mc.admin.entity.param.UserParam;
import com.topnav.mc.base.mc.McMapper;
import org.apache.ibatis.annotations.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.topnav.mc.admin.entity.UserOrganizaiton;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserOrganizaitonMapper extends McMapper<UserOrganizaiton, UserOrganizaitonBean, UserOrganizaitonParam> {
    String commSql = " SELECT uo.*,u.login_name AS userCode,u.name AS userName," +
            " o.code AS orgCode,o.name AS orgName,o.short_name AS shortName," +
            " r.code AS roleCode,r.name AS roleName " +
            " FROM mc_user_organization uo " +
            " LEFT JOIN mc_organization o ON uo.org_id = o.id " +
            " LEFT JOIN mc_user u ON uo.user_id = u.id " +
            " LEFT JOIN mc_role r ON uo.role_id = r.id " +
            " ${ew.customSqlSegment}";

    @Select(commSql)
    UserOrganizaitonBean selectInfoOne(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    List<UserOrganizaitonBean> selectInfoList(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    Page<UserOrganizaitonBean> selectInfoPage(Page<UserOrganizaitonParam> page, @Param(Constants.WRAPPER) Wrapper queryWrapper);
}
